<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp_lib/init.jsp"%>

<script type="text/javascript">
	var add_form_panel = Ext.create("Ext.form.Panel", {
		url : "${path}/cp/user/user/add.htm",
		buttonAlign : "center",
		bodyStyle : "padding: 10px;",
		defaultType : "textfield",
		items : [ {
			fieldLabel : "姓名",
			name : "user.name",
			allowBlank : false
		}, {
			fieldLabel : "用名",
			name : "user.uname",
			allowBlank : false
		}, {
			xtype : "radiogroup",
			fieldLabel : "性别",
			value : 1,
			items : [ {
				boxLabel : "男",
				name : "user.sex",
				checked : true,
				inputValue : "男"
			}, {
				boxLabel : "女",
				name : "user.sex",
				inputValue : "女"
			} ]
		}],
		buttons : [ {
			text : "保存",
			formBind : true, //only enabled once the form is valid
			disabled : true,
			handler : function() {
				var form = this.up("form").getForm();
				if (form.isValid()) {
					form.submit({
						waitMsg : "保存中...",
						success : function(form, action) {
							Ext.Msg.alert("提示", action.result.tip.msg);
							add_form_panel_win.close();
							dataStore.load();
						},
						failure : function(form, action) {
							Ext.Msg.alert("提示", action.result.tip.msg);
						}
					});
				}
			}
		} ]
	});

	var add_form_panel_win = Ext.create("Ext.Window", {
		title : "用户添加",
		closeAction : "hide",
		items : add_form_panel
	});

	function myAdd() {
		add_form_panel.getForm().reset();
		add_form_panel_win.show();
	}
</script>
